var path = require('path');
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
    entry: {
        main: './src/index.js',
        another: './src/another.js',
        blurry: './src/blurry.js',
        diary: './src/diary.js'
    },
    output: {
        filename: '[name].js',
        path: path.resolve(__dirname, 'dist')
    },
    resolve: {
        // alias: {
        //     jquery: 'jquery'
        // }
        alias: {
            'vue$': 'vue/dist/vue.esm.js'
        }
    },
    // externals:{
    //     commonjs: "jquey",
    //     amd: "jquey",
    //     root: "$" // indicates global variable
    // },
    module: {
        rules: [{
            test: /\.css$/,
            use: ['style-loader', 'css-loader']
        }, {
            test: /\.less$/,
            use: ['style-loader', 'css-loader', 'less-loader']
        }, {
            test: /\.(png|svg|jpg|gif|woff|woff2|eot|ttf|otf)$/,
            use: ['file-loader']
        }, {
            test: /\.vue$/,
            loader: 'vue-loader'
        }, {
            test: require.resolve('jquery'),
            use: [{
                loader: 'expose-loader',
                options: '$'
            }]
        }]
    },
    plugins: [
        new HtmlWebpackPlugin({
            filename: 'index.html',
            template: './dist/index.html',
            chunks: ['main', 'another']
        }),
        new HtmlWebpackPlugin({
            filename: 'blurry.html',
            template: './dist/blurry.html',
            chunks: ['blurry']
        }),
        new HtmlWebpackPlugin({
            filename: 'diary.html',
            template: './dist/diary.html',
            chunks: ['diary']
        }),
        new webpack.HotModuleReplacementPlugin()
    ],
    devServer: {
        hot: true, // Tell the dev-server we're using HMR
        contentBase: path.resolve(__dirname, 'dist'),
        publicPath: '/'
    },
    devtool: 'inline-source-map'
};